# 1.导包
import pymysql
# 建立连接
conn =pymysql.connect(host='localhost',port=3306,user='root',password='root',charset='utf8',database='test01')
# 获取游标
cursor=conn.cursor()
# 执行SQL语句
cursor.execute('select version();')
# 查看结果集
res=cursor.fetchone()
print(res[0])
# 关闭游标
cursor.close()
# 关闭链接
conn.close()